//
//  ZLPFindCollectionViewCell.m
//  TangYi
//
//  Created by dllo on 15/10/28.
//  Copyright © 2015年 赵连鹏. All rights reserved.
//

#import "ZLPFindCollectionViewCell.h"

@implementation ZLPFindCollectionViewCell

- (void)dealloc {
    [_descLabel release];
    [_picImageView release];
    [_avatarImageView release];
    [_nameLabel release];
    [_tagLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.picImageView = [[UIImageView alloc ] initWithFrame:CGRectMake(5, 5, self.contentView.frame.size.width - 10, self.contentView.frame.size.height / 3 * 2 - 10)];
        [self.contentView addSubview:self.picImageView];
        [_picImageView release];
        
        
        self.descLabel = [[UILabel alloc] init];
        self.descLabel.font = [UIFont systemFontOfSize:14];
        self.descLabel.numberOfLines = 0;
        self.descLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.descLabel];
        [_descLabel release];
       
        self.descLabel.frame = CGRectMake(5, self.contentView.frame.size.height / 3 * 2, self.contentView.frame.size.width - 10, self.contentView.frame.size.height / 4);
        
        self.tagLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, self.contentView.frame.size.height / 3 * 2 + self.contentView.frame.size.height / 4 - 5, self.contentView.frame.size.width - 10, 30)];
        [self.contentView addSubview:self.tagLabel];
        self.tagLabel.font = [UIFont systemFontOfSize:13];
        self.tagLabel.textColor = [UIColor grayColor];
        [_tagLabel release];
        
        self.avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, self.contentView.frame.size.height / 3 * 2 + self.contentView.frame.size.height / 4, 36, 36)];
        self.avatarImageView.layer.cornerRadius = 18;
        self.avatarImageView.layer.masksToBounds = YES;
        [self.contentView addSubview:self.avatarImageView];
        [_avatarImageView release];
        
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, self.contentView.frame.size.height / 3 * 2 + self.contentView.frame.size.height / 4 + 9, self.contentView.frame.size.width - 45, 30)];
        [self.contentView addSubview:self.nameLabel];
        self.nameLabel.font = [UIFont systemFontOfSize:13];
        self.nameLabel.textColor = [UIColor grayColor];
        [_nameLabel release];
        
//        [self createView];
        
    }
    return self;
}

/* descLabel的自适应 */

//- (void)createView {
//    self.picImageView = [[UIImageView alloc ] init];
//    [self.contentView addSubview:self.picImageView];
//    [_picImageView release];
//    
//    
//    self.descLabel = [[UILabel alloc] init];
//    self.descLabel.font = [UIFont systemFontOfSize:14];
//    self.descLabel.numberOfLines = 0;
//    [self.contentView addSubview:self.descLabel];
//    [_descLabel release];
//    
//
//    self.tagLabel = [[UILabel alloc] init];
//    [self.contentView addSubview:self.tagLabel];
//    [_tagLabel release];
//    
//    self.avatarImageView = [[UIImageView alloc] init];
//    self.avatarImageView.layer.cornerRadius = 15;
//    [self.contentView addSubview:self.avatarImageView];
//    [_avatarImageView release];
//    
//    self.nameLabel = [[UILabel alloc] init];
//    [self.contentView addSubview:self.nameLabel];
//    [_nameLabel release];
//
//}
//
//- (void)layoutSubviews {
//    [super layoutSubviews];
//    self.picImageView.frame = CGRectMake(5, 5, self.contentView.frame.size.width - 10, self.contentView.frame.size.height / 3 * 2);
//    
//    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14], NSFontAttributeName, nil];
//    
//    CGRect rect = [self.descLabel.text boundingRectWithSize:CGSizeMake(375, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
//
//    self.descLabel.frame = CGRectMake(5, self.contentView.frame.size.height / 3 * 2 + 10, self.contentView.frame.size.width - 10, rect.size.height);
//    
//    self.tagLabel.frame = CGRectMake(5, self.contentView.frame.size.height / 3 * 2 + 10 + rect.size.height, self.contentView.frame.size.width - 10, 30);
//    
//    self.avatarImageView.frame = CGRectMake(5, self.contentView.frame.size.height / 3 * 2 + 40 + rect.size.height, 30, 30);
//    
//    self.nameLabel.frame = CGRectMake(40, self.contentView.frame.size.height / 3 * 2 + 40 + rect.size.height, self.contentView.frame.size.width - 45, 30);
//}

@end
